<template>
  <div>
    <el-card shadow="never">
      <header-title title="客户列表详情"></header-title>
    </el-card>
    <el-card shadow="never">
      <div style="line-height: 32px;">基本信息</div>
      <el-row>
        <el-col :span="12">
          <p class="p">
            <b>客户名称：{{defaultValue(modal.name,'暂无信息')}}</b>
          </p>
          <p class="p">
            <b>性别：{{defaultValue(modal.sex,'暂无信息')}}</b>
          </p>
          <p class="p">
            <b>手机号码：{{defaultValue(modal.mobile,'暂无信息')}}</b>
          </p>
          <p class="p">
            <b>微信昵称：{{defaultValue(modal.wxNickName,'暂无信息')}}</b>
          </p>
        </el-col>
        <el-col :span="12">
          <p class="p">
            <b>是否注册：{{defaultValue(modal.registered,'暂无信息')}}</b>
          </p>
          <p class="p">
            <b>创建时间：{{defaultValue(modal.createdAt, '暂无信息')}}</b>
          </p>
          <p class="p">
            <b>是否关注：{{defaultValue(modal.isWechatFlow, '暂无信息')}}</b>
          </p>
          <p class="p">
            <b>支付宝用户id：{{defaultValue(modal.buyerUserId, '暂无信息')}}</b>
          </p>
        </el-col>
      </el-row>
    </el-card>
    <el-card shadow="never">
      <div style="line-height: 32px;">购买记录</div>
    </el-card>
  </div>
</template>

<script>
import HeaderTitle from "@/components/HeaderTitle"
import { isNil } from "@/utils"
export default {
  name: 'MembershipDetail',
  components:{
    HeaderTitle
  },
  data(){
    return {
      membershipId: 0,
      modal: {}
    }
  },
  watch: {
    '$store.state.app.marketId'(val, oldVal){
      const query = this.$route.query.membershipDetails
      this.membershipId = query.membershipId
      this.getaDetailList(this.membershipId)
    }
  },
  mounted(){
    const query = this.$route.query.membershipDetails
    this.membershipId = query.membershipId
    this.getaDetailList(this.membershipId)
  },
  methods: {
    defaultValue (value, defaultValue) {
      if (isNil(value)) {
        return defaultValue
      }
      return value
    },
    // 获取活动列表详情
    getaDetailList(membershipId){
      this.$store.dispatch('membershipList/fetchmDetail',{
        membershipId
      }).then(
        data => {
          if(data.sex === '1'){
            data.sex = '男'
          }else if(data.sex === '2'){
            data.sex = '女'
          }
          if(data.registered === '0'){
            data.registered = '未注册'
          }else if(data.registered === '1'){
            data.registered = '已注册'
          }
          if(data.is_wechat_flow === '0'){
            data.is_wechat_flow = '未关注'
          }else if(data.is_wechat_flow === '1'){
            data.is_wechat_flow = '已关注'
          }
          this.modal = data
        }
      ).catch(err => {
        this.modal = {}
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.p{
  margin-bottom: 10px;
}
</style>
